<template>
  <a-config-provider :locale="locale">
    <router-view></router-view>
  </a-config-provider>
</template>
<script setup>
import zh from "ant-design-vue/es/locale/zh_CN";
import en from "ant-design-vue/es/locale/en_US";
import useLangStore from "./store/lang";
import setTitle from "@/utils/setTitle";
// import { watch } from "vue";
const langStore = useLangStore();
const langs = {
  zh,
  en,
};
const locale = ref(langs[langStore.lang]);
// 监听当langStore的lang值变化,修改locale的值

const route = useRoute();
watch(
  () => langStore.lang,
  () => {
    locale.value = langs[langStore.lang];
    setTitle(route);
  }
);
//动态切换网站标题
//1.监听路由

const router = useRouter();
watch(
  () => router.currentRoute.value,
  () => {
    setTitle(route);
  }
);
</script>

<style scoped>
html,
body,
#app {
  height: 100vh;
}
</style>
